import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path'; // 引入path模块

/** 自动导入插件 */
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';

/** 引入svg插件 */
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';

export default defineConfig(() => {
	return {
		plugins: [
			vue(),
			AutoImport({
				resolvers: [ElementPlusResolver()]
			}),
			Components({
				resolvers: [ElementPlusResolver()]
			}),
			createSvgIconsPlugin({
				iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
				symbolId: 'icon-[dir]-[name]'
			})
		],
		// 配置src目录别名
		resolve: {
			alias: {
				'@': path.resolve(__dirname, 'src') // 相对路径别名配置，使用 @ 代替 src
			}
		},
		server: {
			host: '0.0.0.0',
			port: 8856,
			proxy: {}
		},
		css: {
			preprocessorOptions: {
				scss: {
					javascriptEnabled: true,
					additionalData: '@import "./src/styles/variable.scss";'
				}
			}
		}
	};
});
